#pragma once

#include <vector>

class Article;
class StopWords;
class DocumentIndexData;
class PorterStemmingAlgorithm;
class TermInfo;

class TermData
{
public:
	enum StemmingAlgorithm
	{
		SA_Porter = 0,
		SA_Count
	};

	TermData(std::string& outputPath, std::string& tfOutputName, std::string& dicOutputName, std::string& docOutputName);
	virtual ~TermData();
	void AddArticle(Article* article);
	void AddStopWords(char* filename);
	void Export(DocumentIndexData* documentData);
	void ExportDictionary();
	unsigned int GetTermIndex(std::string& word);
	typedef std::map<std::string, unsigned int> Dictionary;
	typedef std::map<unsigned int, TermInfo*> TermMap;
	typedef std::map<std::string, DocumentIndexData*> DocumentMap;
private:
	void ParseString(DocumentIndexData* documentData, std::string& str, int multiplier = 1);
	StopWords* m_StopWords;
	PorterStemmingAlgorithm* m_PorterStemmingAlgorithm;
	std::vector<std::string> Tokenize(std::string& str,std::string& delimiters);
	StemmingAlgorithm m_Algorithm;
	
	// Output streams
	std::ofstream m_TFStream;
	std::ofstream m_DicStream;
	std::ofstream m_DocStream;
	
	// Dictionary
	unsigned int m_DocumentCount;
	unsigned int m_TermCount;
	unsigned int m_TotalDFCount;
	Dictionary m_Dictionary;

	DocumentMap m_DocumentMap;
	TermMap m_TermMap;
};